From: kaf24@firebug.cl.cam.ac.uk Date: Fri, 19 May 2006 15:08:51 +0000 (+0100) Subject: [XEND] An empirical and more conservative memory-overhead estimate for PV and HVM... X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~16047^2~23^2~1 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=37d3005e6271fa2c613f466068d6c0f38943c754;p=xen.git [XEND] An empirical and more conservative memory-overhead estimate for PV and HVM guests. This patch calculates the overhead needed for HVM domains. If HVM is supported by the hardware, I add a little ballooning overhead to paravirtualized VMs also, to avoid low-memory situations. (There are various unchecked alloc_domheap_pages calls in shadow*.c that I am trying to avoid tripping over for now...) The values in this patch work fine on 32 bit; I may update them later based on feedback and/or testing on 64 bit. Signed-off-by: Charles Coffing --- diff --git a/tools/python/xen/xend/image.py b/tools/python/xen/xend/image.py index 43ed39993c..6d2da07cd6 100644 --- a/tools/python/xen/xend/image.py +++ b/tools/python/xen/xend/image.py @@ -19,6 +19,7 @@ import os, string import re +import math import xen.lowlevel.xc from xen.xend import sxp @@ -141,11 +142,13 @@ class ImageHandler: % (self.ostype, self.vm.getDomid(), str(result))) - def getDomainMemory(self, mem): + def getDomainMemory(self, mem_kb): """@return The memory required, in KiB, by the domain to store the - given amount, also in KiB. This is normally just mem, but HVM domains - have overheads to account for.""" - return mem + given amount, also in KiB. This is normally just mem, but if HVM is + supported, keep a little extra free.""" + if 'hvm' in xc.xeninfo()['xen_caps']: + mem_kb += 4*1024; + return mem_kb def buildDomain(self): """Build the domain. Define in subclass.""" @@ -377,15 +380,20 @@ class HVMImageHandler(ImageHandler): os.waitpid(self.pid, 0) self.pid = 0 - def getDomainMemory(self, mem): + def getDomainMemory(self, mem_kb): """@see ImageHandler.getDomainMemory""" - page_kb = 4 - extra_pages = 0 if os.uname()[4] == 'ia64': page_kb = 16 # ROM size for guest firmware, ioreq page and xenstore page extra_pages = 1024 + 2 - return mem + extra_pages * page_kb + else: + page_kb = 4 + # This was derived emperically: + # 2.4 MB overhead per 1024 MB RAM + 8 MB constant + # + 4 to avoid low-memory condition + extra_mb = (2.4/1024) * (mem_kb/1024.0) + 12; + extra_pages = int( math.ceil( extra_mb*1024 / page_kb )) + return mem_kb + extra_pages * page_kb def register_shutdown_watch(self): """ add xen store watch on control/shutdown """